
package com.epam.android.training;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * File selector open helper
 * 
 * @author Natallia_Kukharchyk
 */
public class FileSelectorOpenHelper extends SQLiteOpenHelper {

  public static final String TABLE_NAME = "selected_files";

  private static final String DATABASE_NAME = "filesdb";

  public static final String FILE_NAME = "file_name";

  private static final String TABLE_CREATE = "CREATE TABLE " + TABLE_NAME + " (_id integer primary key autoincrement,"
      + FILE_NAME + " text not null);";

  private static final int DATABASE_VERSION = 4;

  public FileSelectorOpenHelper(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
  }

  @Override
  public void onCreate(SQLiteDatabase db) {
    db.execSQL(TABLE_CREATE);
  }

  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
    onCreate(db);
  }

}
